#coding:utf-8
"""
新增机房位置等基础信息
"""
import database
import web
import public
import new_servicer

class main(new_servicer.main):
    def __init__(self):
        self.db=database.database()
        self.render=public.render

    @public.catch_exception
    @public.check_login
    def GET(self):
        return self.render.new_baseinfo()

    @public.catch_exception
    @public.check_login
    def POST(self):
        user_input=web.input()
        for (k,v) in user_input.iteritems():
            v=[line.strip() for line in v.splitlines() if line.strip()!='']
            for info in v:
                print 'self.db.insert_%s("%s")'%(k,info)
                exec('self.db.insert_%s("%s")'%(k,info))
        web.seeother('/new_baseinfo')
